<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>修改账号</title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /><!-- 控制浏览器文件模式为IE8 -->
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="js/artDialog/skins/default.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/artDialog/artDialog.js?skin=blue"></script>
<script src="js/artDialog/plugins/iframeTools.js"></script>
<script type="text/javascript" src="js/operamasks-ui.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/elegant/om-all.css" />
<script> 
(function (config) {
    config['lock'] = true;
    config['fixed'] = true;
    config['okVal'] = 'Ok';
    config['cancelVal'] = 'Cancel';
})(art.dialog.defaults);
</script>
<script>
function submitForm() {
	var loginName = document.getElementById("loginName").value;
	var adminId = document.getElementById("adminId").value;
	var email = document.getElementById("email").value;
	var telePhone = document.getElementById("telePhone").value;
	var phone = document.getElementById("phone").value;
	var realName = document.getElementById("realName").value;
	var description = document.getElementById("description").value;
	var flag = true;
	
	if(email == null || email == ""){
	}else{
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter.test(email)) {
			art.dialog.tips('您的电子邮件格式不正确！', 1.5);
			flag=false;
			return ;
		}
	}
	
	
	if(telePhone == null || telePhone == ""){
	} else {
		var m = /^\d{3}\+\d{5}|\d{4}\+\d{4}$/;
		if(!m.test(telePhone)){
			art.dialog.tips('分机格式不正确！', 1.5);
			flag = false;
			return;
		}
	}
	
	var patrn = /^(13[0-9]|15[0-9]|18[0-9]|14[0-9])\d{8}$/; //检测手机号码	
	if(phone == null || phone == ""){}else{
		if(!patrn.test(phone)){
			art.dialog.tips('您的手机号码格式不正确！', 1.5);
			flag=false;
			return false;
		}
	}
	
	if(realName == null || realName == ""){
		art.dialog.tips('真实名不能为空！', 1.5);
		flag = false;
		return;
	}
	
	if(description.length>80){
		art.dialog.tips('描述不能超過80個字！', 1.5);
		flag = false;
		return;
	}
	
	if(flag){
		art.dialog({
			id:'art1',
			title:'溫馨提示',
			content :"確認修改個人信息嗎",
			width:'27.8%',
			height:'11.6%',
			ok:function(){
				$.ajax({
					url: "${pageContext.request.contextPath}/adminUser.do?action=editUser",//请求的action路径
					cache: false,
					async: false,
					type: 'post',
					dataType : "json",
					timeout : 2000,
					data: { 
						loginName : loginName, 
						adminId : adminId, 
						email : email, 
						telePhone : telePhone,
						phone : phone,
						realName : realName,
						description : description,
					},
					error: function(XMLHttpRequest, textStatus, errorThrown) {
			            alert(XMLHttpRequest.status);
			            alert(XMLHttpRequest.readyState);
			            alert(textStatus);
			            alert("修改失敗，請與管理員聯繫!");
			        },
					success:function(data){ //请求成功后处理函数
						if (data.success == "true") {
							art.dialog.tips("修改成功");
						} else {
							art.dialog.tips("修改失敗，請與管理員聯繫");
						}
					}
				}); 
			},
			cancel:true
		});
	}
}
</script>
</head>
<body>

	<div class="place">
	    <span>位置：</span>
	    <ul class="placeul">
	    <li>首页</li>
		<li>個人中心</li>
	    <li>我的設置</li>
		<li>基本信息</li>
	    </ul>
    </div>
    <div class="formbody">
    	<div class="formtitle"><span>基本信息</span></div>
		<form id="form1" action="./adminUser.do?action=editUser" method="post">
			<ul class="forminfo">
				<li>
					<label>用户登录名：</label>
					<input id="loginName" type="text" disabled="disabled" value="${user.loginName }" name="loginName" class="dfinput" autocomplete="off"/>
					<input type="hidden" name="adminId" id="adminId" value="${user.adminId }"></input>
				</li>
				<li>
					<label>Email：</label>
					<input id="email" type="text" name="email" value="${user.email }" class="dfinput" autocomplete="off"/>
				</li>
				<li>
					<label>分机：</label>
					<input id="telePhone" type="text" name="telePhone" value="${user.telePhone }" class="dfinput" autocomplete="off"/>
				</li>
				<li>
					<label>用户真实名：</label>
				    <input id="realName" type="text" name="realName" value="${user.realName }" class="dfinput" autocomplete="off"/><i>&nbsp;&nbsp;*必填</i>
				</li>
				<li>
					<label>电话：</label>
				    <input id="phone" type="text" name="phone" value="${user.phone }" class="dfinput" autocomplete="off"/>
				</li>
				<li>
					<label>描述：</label>
					<input id="description" type="text" name="description" value="${user.description }" class="dfinput" autocomplete="off"/>
				</li>
			    <li>
					<label>&nbsp;</label>
					<input name="" type="button" id="save" onclick="submitForm();" class="btn" value="确定修改"/> 
					<!-- <input style="margin-left:100px;" onclick="javascript:document.location.href = './adminUser.do?action=list';" type="button" class="cancel" value="取消修改" /> -->
				</li>
		    </ul>   
	    </form>
	</div>
</body>
</html>